#include "StdAfx.h"
#include "timeinfo.h"

#include <stdio.h>

	float TimeInfo::GetTimePass ()
	{
		return TimePass ;
	}

	void TimeInfo::GetFPS (char* buf, int bufSize)
	{
		sprintf_s(buf, bufSize, "FPS:%d", FPS) ;
	}

	void TimeInfo::Work ()
	{
		{
			int CurTime = GetTickCount () ;

			if (PreFrameTime != 0)
				TimePass = (CurTime-PreFrameTime)/1000.0f ;
			else
				TimePass = 0 ;

			PreFrameTime = CurTime ;
		}

			TotalFrame ++ ;

			if (TotalFrame == 50)
			{
				int CurTime = GetTickCount () ;

				FPS = (50*1000)/(CurTime-PreRecordTime) ;
	
				PreRecordTime = CurTime ;
				TotalFrame = 0 ;

			}
	}

	TimeInfo::TimeInfo ():TotalFrame(0),PreRecordTime(0),PreFrameTime(0),TimePass(0)
	{
	}

